package com.crt.nexus.security.authentication;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class AuthenticationToken extends AbstractAuthenticationToken {

    private final Object principal;
    private final Object credentials;
    private final Object details;

    /**
     * This constructor can be safely used by any code that wishes to create a
     * <code>ReactiveAuthenticationToken</code>, as the isAuthenticated()
     * will return <code>false</code>.
     */
    public AuthenticationToken(Object principal, Object credentials, Object details) {
        super(null);
        this.principal = principal;
        this.credentials = credentials;
        this.details = details;
    }

    /**
     * This constructor should only be used by <code>AuthenticationManager</code> or
     * <code>AuthenticationProvider</code> implementations that are satisfied with
     * producing a trusted (i.e. {@link #isAuthenticated()} = <code>true</code>)
     * authentication token.
     */
    public AuthenticationToken(Object principal, Object credentials, Object details, Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
        this.principal = principal;
        this.credentials = credentials;
        this.details = details;
    }

    @Override
    public Object getCredentials() {
        return this.credentials;
    }

    @Override
    public Object getPrincipal() {
        return this.principal;
    }

    @Override
    public Object getDetails() {
        return this.details;
    }

}
